//: Playground - noun: a place where people can play

import Cocoa


struct Inputs: OptionSetType {
    let rawValue: Int
    
    static let user = Inputs(rawValue: 1)//1
    static let pass = Inputs(rawValue: 1 << 1)//10
    static let mail = Inputs(rawValue: 1 << 2)//100
}

//判断是否全部输入
extension Inputs{
     func isAllOK() -> Bool{
        //return self == [.user,.pass,.mail]
        //选项的数目
        let count = 3
        //找到几项
        var found = 0
        //在数目范围内查找，若找到，次数增加
        /*for time in 0..<count {
            if self.contains(Inputs(rawValue:1 << time)){
                found++
            }
        }*/
        
        for time in 0..<count where contains(Inputs(rawValue:1 << time)){
            found++
        }
        //比较次数与选项的数目
        return found == count
    }
}

let possibleInputs :Inputs = [.user,.pass]

possibleInputs.isAllOK()
possibleInputs.rawValue
possibleInputs.contains(.mail)